<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>仓库管理</title>
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="./images/favicon.png" />

    <!-- <link href="./css/style.css" rel="stylesheet" /> -->

    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/jsgrid/jsgrid-theme.min.css" rel="stylesheet" />
    <link href="assets/css/lib/jsgrid/jsgrid.min.css" type="text/css" rel="stylesheet" />
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/helper.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">

    <!-- jquery vendor -->
    <script src="assets/js/lib/jquery.min.js"></script>
    <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>

    <script>
        //重设指定组的分区选项
        function resetWarehouseSelect(groupName) {
            $("#" + groupName + "_warehouseSectionSelect option").remove();
            $("#" + groupName + "_warehouseSectionSelect").append("<option value=\"nullSelect\">选择一个分区</option>");
            $("#" + groupName + "_warehouseSectionSelect").attr("disabled", true);
        }
    </script>

    <script>
        function setSectionData(groupName, data) {
            $("#" + groupName + "_warehouseSectionSelect option").remove();
            $("#" + groupName + "_warehouseSectionSelect").append("<option value=\"nullSelect\">选择一个分区</option>");
            $.each(data, function (k, v) {
                $("#" + groupName + "_warehouseSectionSelect").append("<option value =\"" + v.warehouseSectionNo + "\">" + v.warehouseSectionName + "</option>");
                $("#" + groupName + "_warehouseSectionSelect").attr("disabled", false);
            })
        }
    </script>

    <script>
        //加载仓库信息数据
        $(document).ready(function () {
            var requestObj = {};
            requestObj["requestService"] = "WarehouseShelfManageService";
            requestObj["requestMethod"] = "selectAllWarehouse";
            var data = {};
            requestObj["data"] = data;
            var requestJson = JSON.stringify(requestObj);
            $.ajax({
                type: "POST",
                url: "http://192.168.70.135:80/api/",
                contentType: "application/json",
                data: requestJson,
                async: false,
                success: function (msg) {
                    window.warehousedb.clients = msg.data;
                    $("#jsGrid_warehouseList").jsGrid("loadData");
                    $.each(msg.data, function (k, v) {
                        $("#warehouseSection_warehouseSelect").append("<option value =\"" + v.warehouseNo + "\">" + v.warehouseName + "</option>");
                        $("#warehouseShelf_warehouseSelect").append("<option value =\"" + v.warehouseNo + "\">" + v.warehouseName + "</option>");
                    })
                }
            });
        });
    </script>

    <script>
        //封装获取指定仓库分区信息方法
        function selectAllWarehouseSection(selectWarehousenNo) {
            var requestObj = {};
            requestObj["requestService"] = "WarehouseShelfManageService";
            requestObj["requestMethod"] = "selectAllWarehouseSection";
            var data = {};
            data.warehouseNo = selectWarehousenNo;
            requestObj["data"] = data;
            var requestJson = JSON.stringify(requestObj);
            var msg;
            $.ajax({
                type: "POST",
                url: "http://192.168.70.135:80/api/",
                contentType: "application/json",
                async: false,
                data: requestJson,
                success: function (response) {
                    msg = response;
                }
            });
            return msg;
        }
    </script>

    <script>
        //封装获取指定分区货架信息方法
        function selectAllWarehouseSectionShelf(selectWarehouseSectionnNo) {
            var requestObj = {};
            requestObj["requestService"] = "WarehouseShelfManageService";
            requestObj["requestMethod"] = "selectAllWarehouseShelf";
            var data = {};
            data.warehouseSectionNo = selectWarehouseSectionnNo;
            requestObj["data"] = data;
            var requestJson = JSON.stringify(requestObj);
            var msg;
            $.ajax({
                type: "POST",
                url: "http://192.168.70.135:80/api/",
                contentType: "application/json",
                async: false,
                data: requestJson,
                success: function (response) {
                    msg = response;
                }
            });
            return msg;
        }
    </script>

    <script>
        //分区管理-仓库选择事件
        $(document).ready(function () {
            $("#warehouseSection_warehouseSelect").change(function () {
                var selectWarehouseNo = $("#warehouseSection_warehouseSelect").val();
                if (selectWarehouseNo == "nullSelect") {
                    return;
                }
                var msg = selectAllWarehouseSection(selectWarehouseNo);
                window.warehouseSectiondb.clients = msg.data;
                $("#jsGrid_warehouseSectionList").jsGrid("loadData");
            })
        })
    </script>

    <script>
        //货架管理-仓库选择事件
        $(document).ready(function () {
            $("#warehouseShelf_warehouseSelect").change(function () {
                var selectWarehouseNo = $("#warehouseShelf_warehouseSelect").val();
                resetWarehouseSelect("warehouseShelf");
                if (selectWarehouseNo == "nullSelect") {
                    return;
                }
                var msg = selectAllWarehouseSection(selectWarehouseNo);
                setSectionData("warehouseShelf", msg.data);
            })
        })
    </script>

    <script>
        //货架管理-分区选择事件
        $(document).ready(function () {
            $("#warehouseShelf_warehouseSectionSelect").change(function () {
                var selectWarehouseSectionNo = $("#warehouseShelf_warehouseSectionSelect").val();
                if (selectWarehouseSectionNo == "nullSelect") {
                    return;
                }
                var msg = selectAllWarehouseSectionShelf(selectWarehouseSectionNo);
                window.warehouseShelfdb.clients = msg.data;
                $("#jsGrid_warehouseShelfList").jsGrid("loadData");
            })
        })
    </script>

    <script>
        //点击submit_warehouse按钮
        $(document).ready(function () {
            $("#submit_warehouse").click(function () {
                if (window.warehouseListUpdate) {
                    //执行更新
                    var requestObj = {};
                    requestObj["requestService"] = "WarehouseShelfManageService";
                    requestObj["requestMethod"] = "updateWarehouseInfo";
                    var data = {};
                    data["warehouseNo"] = window.warehouseListUpdatingNo;
                    data["warehouseName"] = $("#warehouseName").val();
                    data["warehouseInfo"] = $("#warehouseInfo").val();
                    requestObj["data"] = data;
                    var requestJson = JSON.stringify(requestObj);
                    $.ajax({
                        type: "POST",
                        url: "http://192.168.70.135:80/api/",
                        contentType: "application/json",
                        data: requestJson,
                        async: false,
                        success: function (msg) {
                            location.reload();
                        }
                    });
                    return;
                }
                //执行添加
                var requestObj = {};
                requestObj["requestService"] = "WarehouseShelfManageService";
                requestObj["requestMethod"] = "addWarehouseInfo";
                var data = {};
                data["warehouseName"] = $("#warehouseName").val();
                data["warehouseInfo"] = $("#warehouseInfo").val();
                requestObj["data"] = data;
                var requestJson = JSON.stringify(requestObj);
                $.ajax({
                    type: "POST",
                    url: "http://192.168.70.135:80/api/",
                    contentType: "application/json",
                    data: requestJson,
                    async: false,
                    success: function (msg) {
                        location.reload();
                    }
                });
            });
        });
    </script>

    <script>
        //点击submit_warehouseShection按钮
        $(document).ready(function () {
            $("#submit_warehouseShection").click(function () {
                if (window.warehouseSectionListUpdate) {
                    //执行更新
                    var requestObj = {};
                    requestObj["requestService"] = "WarehouseShelfManageService";
                    requestObj["requestMethod"] = "updateWarehouseSectionInfo";
                    var data = {};
                    data["warehouseSectionNo"] = window.warehouseSectionListUpdatingNo;
                    data["warehouseNo"] = $("#warehouseSection_warehouseSelect").val();
                    data["warehouseSectionName"] = $("#warehouseSectionName").val();
                    data["warehouseSectionInfo"] = $("#warehouseSectionInfo").val();
                    requestObj["data"] = data;
                    var requestJson = JSON.stringify(requestObj);
                    $.ajax({
                        type: "POST",
                        url: "http://192.168.70.135:80/api/",
                        contentType: "application/json",
                        data: requestJson,
                        async: false,
                        success: function (msg) {
                            location.reload();
                        }
                    });
                    return;
                }
                //执行添加
                var requestObj = {};
                requestObj["requestService"] = "WarehouseShelfManageService";
                requestObj["requestMethod"] = "addWarehouseSectionInfo";
                var data = {};
                data["warehouseNo"] = $("#warehouseSection_warehouseSelect").val();
                data["warehouseSectionName"] = $("#warehouseSectionName").val();
                data["warehouseSectionInfo"] = $("#warehouseSectionInfo").val();
                requestObj["data"] = data;
                var requestJson = JSON.stringify(requestObj);
                $.ajax({
                    type: "POST",
                    url: "http://192.168.70.135:80/api/",
                    contentType: "application/json",
                    data: requestJson,
                    async: false,
                    success: function (msg) {
                        location.reload();
                    }
                });
            });
        });
    </script>

    <script>
        //点击submit_warehouseShelf按钮
        $(document).ready(function () {
            $("#submit_warehouseShelf").click(function () {
                if (window.warehouseShelfListUpdate) {
                    //执行更新
                    var requestObj = {};
                    requestObj["requestService"] = "WarehouseShelfManageService";
                    requestObj["requestMethod"] = "updateWarehouseShelfInfo";
                    var data = {};
                    data["warehouseShelfNo"] = window.warehouseShelfListUpdatingNo;
                    data["warehouseSectionNo"] = $("#warehouseShelf_warehouseSectionSelect").val();
                    data["warehouseShelfName"] = $("#warehouseShelfName").val();
                    data["warehouseShelfInfo"] = $("#warehouseShelfInfo").val();
                    requestObj["data"] = data;
                    var requestJson = JSON.stringify(requestObj);
                    $.ajax({
                        type: "POST",
                        url: "http://192.168.70.135:80/api/",
                        contentType: "application/json",
                        data: requestJson,
                        async: false,
                        success: function (msg) {
                            location.reload();
                        }
                    });
                    return;
                }
                //执行添加
                var requestObj = {};
                requestObj["requestService"] = "WarehouseShelfManageService";
                requestObj["requestMethod"] = "addWarehouseShelfInfo";
                var data = {};
                data["warehouseSectionNo"] = $("#warehouseShelf_warehouseSectionSelect").val();
                data["warehouseShelfName"] = $("#warehouseShelfName").val();
                data["warehouseShelfInfo"] = $("#warehouseShelfInfo").val();
                requestObj["data"] = data;
                var requestJson = JSON.stringify(requestObj);
                $.ajax({
                    type: "POST",
                    url: "http://192.168.70.135:80/api/",
                    contentType: "application/json",
                    data: requestJson,
                    async: false,
                    success: function (msg) {
                        location.reload();
                    }
                });
            });
        });
    </script>

</head>

<body>

    <script src="./common.js"></script>
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div id="main-content">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="card-title">
                                        <h4>仓库列表 </h4>
                                    </div>
                                </div>
                                </br>
                                <div class="card-body">
                                    <div class="jsgrid-table-panel">
                                        <div id="jsGrid_warehouseList"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="card-title">
                                        <h4>仓库详情 </h4>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                        <div class="row">
                                            <div class="col-lg-4">
                                                <div class="form-group">
                                                    <label>仓库名称</label>
                                                    <input id="warehouseName" type="text" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-lg-12">
                                                <div class="form-group">
                                                    <label>仓库描述</label>
                                                    <textarea id="warehouseInfo" class="form-control" rows="10"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <button type="button" class="btn btn-primary m-b-10 m-l-5"
                                            id="submit_warehouse">添加</button>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="card-title">
                                        <h4>仓库分区列表 </h4>
                                    </div>
                                </div>
                                <br />

                                <div class="card-body">
                                    <h6>选择一个仓库</h5>
                                        <div class="row">
                                            <div class="col-lg-4">
                                                <div class="form-group">
                                                    <label>仓库</label>
                                                    <select id="warehouseSection_warehouseSelect" type="dropdown"
                                                        class="form-control">
                                                        <option value="nullSelect">
                                                            选择一个仓库</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="jsgrid-table-panel">
                                            <div id="jsGrid_warehouseSectionList"></div>
                                        </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="card-title">
                                        <h4>仓库分区详情 </h4>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                        <div class="row">
                                            <div class="col-lg-4">
                                                <div class="form-group">
                                                    <label>仓库分区名称</label>
                                                    <input id="warehouseSectionName" type="text" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-lg-12">
                                                <div class="form-group">
                                                    <label>仓库分区描述</label>
                                                    <textarea id="warehouseSectionInfo" class="form-control"
                                                        rows="10"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <button type="button" class="btn btn-primary m-b-10 m-l-5"
                                            id="submit_warehouseShection">添加</button>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="card-title">
                                        <h4>仓库货架列表 </h4>
                                    </div>
                                </div>
                                </br>
                                <div class="card-body">
                                    <br />
                                    <h6>选择一个仓库</h5>
                                        <div class="row">
                                            <div class="col-lg-4">
                                                <div class="form-group">
                                                    <label>仓库</label>
                                                    <select id="warehouseShelf_warehouseSelect" type="dropdown"
                                                        class="form-control">
                                                        <option value="nullSelect">
                                                            选择一个仓库</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="col-lg-4">
                                                <div class="form-group">
                                                    <label>分区</label>
                                                    <select id="warehouseShelf_warehouseSectionSelect" type="dropdown"
                                                        class="form-control" disabled=true>
                                                        <option value="nullSelect">
                                                            选择一个分区</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="jsgrid-table-panel">
                                            <div id="jsGrid_warehouseShelfList"></div>
                                        </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="card">
                                <div class="card-header">
                                    <div class="card-title">
                                        <h4>仓库货架详情 </h4>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                        <div class="row">
                                            <div class="col-lg-4">
                                                <div class="form-group">
                                                    <label>仓库货架名称</label>
                                                    <input id="warehouseShelfName" type="text" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-lg-12">
                                                <div class="form-group">
                                                    <label>仓库货架描述</label>
                                                    <textarea id="warehouseShelfInfo" class="form-control"
                                                        rows="10"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                        <button type="button" class="btn btn-primary m-b-10 m-l-5"
                                            id="submit_warehouseShelf">添加</button>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <!-- nano scroller -->
        <script src="assets/js/lib/menubar/sidebar.js"></script>
        <script src="assets/js/lib/preloader/pace.min.js"></script>
        <!-- sidebar -->

        <!-- JS Grid Scripts Start-->
        <script>
            (function () {

                var warehousedb = {

                    loadData: function (filter) {
                        return window.warehousedb.clients;
                    },

                    insertItem: function (insertingClient) {
                        window.warehousedb.clients.push(insertingClient);
                    },

                    updateItem: function (updatingClient) { },

                    deleteItem: function (deletingClient) {
                        var clientIndex = $.inArray(deletingClient, window.warehousedb.clients);
                        window.warehousedb.clients.splice(clientIndex, 1);
                    }

                };

                window.warehousedb = warehousedb;

                window.warehousedb.clients = [
                ];

            }());
        </script>
        <script src="assets/js/lib/jsgrid/jsgrid.core.js"></script>
        <script src="assets/js/lib/jsgrid/jsgrid.load-indicator.js"></script>
        <script src="assets/js/lib/jsgrid/jsgrid.load-strategies.js"></script>
        <script src="assets/js/lib/jsgrid/jsgrid.sort-strategies.js"></script>
        <script src="assets/js/lib/jsgrid/jsgrid.field.js"></script>
        <script src="assets/js/lib/jsgrid/fields/jsgrid.field.text.js"></script>
        <script src="assets/js/lib/jsgrid/fields/jsgrid.field.number.js"></script>
        <script src="assets/js/lib/jsgrid/fields/jsgrid.field.select.js"></script>
        <script src="assets/js/lib/jsgrid/fields/jsgrid.field.checkbox.js"></script>
        <script src="assets/js/lib/jsgrid/fields/jsgrid.field.control.js"></script>
        <script>
            $(function () {
                $("#jsGrid_warehouseList").jsGrid({
                    height: "100%",
                    width: "100%",
                    filtering: false,
                    editing: false,
                    inserting: false,
                    sorting: true,
                    paging: true,
                    autoload: true,
                    pageSize: 15,
                    pageButtonCount: 4,
                    deleteConfirm: "Do you really want to delete the client?",
                    controller: warehousedb,
                    noDataContent: "目前是空的......",
                    fields: [
                        { name: "warehouseName", title: "仓库名称", type: "text", width: 50 },
                        { name: "warehouseInfo", title: "商品描述", type: "text", width: 220 }
                    ],
                    rowClick: function (selectRow) {
                        var selectRowData = selectRow.item;
                        window.warehouseListUpdate = true;
                        window.warehouseListUpdatingNo = selectRowData.warehouseNo;
                        $("#submit_warehouse").text("确定修改");
                        $.each(selectRowData, function (k, v) {
                            $("#" + k).val(v);
                        })
                    }
                });
            });
        </script>

        <script>
            (function () {

                var warehouseSectiondb = {

                    loadData: function (filter) {
                        return window.warehouseSectiondb.clients;
                    },

                    insertItem: function (insertingClient) {
                        window.warehouseSectiondb.clients.push(insertingClient);
                    },

                    updateItem: function (updatingClient) { },

                    deleteItem: function (deletingClient) {
                        var clientIndex = $.inArray(deletingClient, window.warehouseSectiondb.clients);
                        window.warehouseSectiondb.clients.splice(clientIndex, 1);
                    }

                };

                window.warehouseSectiondb = warehouseSectiondb;

                window.warehouseSectiondb.clients = [
                ];

            }());
        </script>

        <script>
            $(function () {
                $("#jsGrid_warehouseSectionList").jsGrid({
                    height: "100%",
                    width: "100%",
                    filtering: false,
                    editing: false,
                    inserting: false,
                    sorting: true,
                    paging: true,
                    autoload: true,
                    pageSize: 15,
                    pageButtonCount: 4,
                    deleteConfirm: "Do you really want to delete the client?",
                    controller: warehouseSectiondb,
                    noDataContent: "目前是空的......",
                    fields: [
                        { name: "warehouseSectionName", title: "仓库分区名称", type: "text", width: 50 },
                        { name: "warehouseSectionInfo", title: "商品分区描述", type: "text", width: 220 },
                    ],
                    rowClick: function (selectRow) {
                        var selectRowData = selectRow.item;
                        window.warehouseSectionListUpdate = true;
                        window.warehouseSectionListUpdatingNo = selectRowData.warehouseSectionNo;
                        $("#submit_warehouseShection").text("确定修改");
                        $.each(selectRowData, function (k, v) {
                            $("#" + k).val(v);
                        })
                    }
                });
            });
        </script>

        <script>
            (function () {

                var warehouseShelfdb = {

                    loadData: function (filter) {
                        return window.warehouseShelfdb.clients;
                    },

                    insertItem: function (insertingClient) {
                        window.warehouseShelfdb.clients.push(insertingClient);
                    },

                    updateItem: function (updatingClient) { },

                    deleteItem: function (deletingClient) {
                        var clientIndex = $.inArray(deletingClient, window.warehouseShelfdb.clients);
                        window.warehouseShelfdb.clients.splice(clientIndex, 1);
                    }

                };

                window.warehouseShelfdb = warehouseShelfdb;

                window.warehouseShelfdb.clients = [
                ];

            }());
        </script>

        <script>
            $(function () {
                $("#jsGrid_warehouseShelfList").jsGrid({
                    height: "100%",
                    width: "100%",
                    filtering: false,
                    editing: false,
                    inserting: false,
                    sorting: true,
                    paging: true,
                    autoload: true,
                    pageSize: 15,
                    pageButtonCount: 4,
                    deleteConfirm: "Do you really want to delete the client?",
                    controller: warehouseShelfdb,
                    noDataContent: "目前是空的......",
                    fields: [
                        { name: "warehouseShelfName", title: "仓库货架名称", type: "text", width: 50 },
                        { name: "warehouseShelfInfo", title: "商品货架描述", type: "text", width: 220 },
                    ],
                    rowClick: function (selectRow) {
                        var selectRowData = selectRow.item;
                        window.warehouseShelfListUpdate = true;
                        window.warehouseShelfListUpdatingNo = selectRowData.warehouseShelfNo;
                        $("#submit_warehouseShelf").text("确定修改");
                        $.each(selectRowData, function (k, v) {
                            $("#" + k).val(v);
                        })
                    }
                });
            });
        </script>
        <!-- JS Grid Scripts End-->

        <script>

        </script>

</body>

</html>